package com.koron.order.cockpitStats.business.bean.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.text.NumberFormat;

/**
 * @ClassName OrderPassRateGatherVo
 * @description 工单合格率统计
 * @Author zhouj
 * @Date 2022/5/25 14:39
 */
@Data
public class OrderPassRateGatherVo {

    @ApiModelProperty("组织id")
    private String orgId;

    @ApiModelProperty("组织名称")
    private String orgName;

    @ApiModelProperty("工单总数")
    private int total;

    @ApiModelProperty("合格数")
    private int passNum;

    @ApiModelProperty("合格率")
    private String passRate;

    public String getPassRate() {
        //仅在json返回处理

        if (total == 0 || passNum == 0) {
            return "0";
        }

        //isFinishOnTime/total
        // 创建一个数值格式化对象
        NumberFormat numberFormat = NumberFormat.getInstance();
        // 设置精确到小数点后2位
        numberFormat.setMaximumFractionDigits(2);

        return numberFormat.format((float) passNum / (float) total * 100);
    }
}
